home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 17 / CU Amiga Magazine's Super CD-ROM 17 (1997)(EMAP Images)(GB)[!][issue 1997-12].iso / CUCD / Programming / Gui4Cli / Docs / Tutorials / GoSub.gc < prev    next >
Encoding:
Gui4CLI script  |  1980-01-03  |  2.8 KB  |  108 lines

  1. G4C
  2.  
  3. WinBig -1 -1 300 210 "GoSub.gc"
  4. WinType 11110001
  5. usetopaz
  6.  
  7. ; ---- This is all the diagram stuff ...
  8. BOX 0 0 0 0 OUT RIDGE
  9. SQUARE 10 24 40 16 2 NOFILL
  10. SQUARE 20 50 20 10 2 FILL
  11. SQUARE 20 70 20 10 2 FILL
  12. SQUARE 20 90 20 10 2 FILL
  13. SQUARE 10 110 40 16 2 NOFILL
  14. LINE 30 40 30 50 2
  15. LINE 30 60 30 70 2
  16. LINE 30 80 30 90 2
  17. LINE 30 100 30 110 2
  18. LINE 40 55 120 55 2
  19. LINE 40 75 120 75 2
  20. LINE 40 95 120 95 2
  21. LINE 4 134 294 134 1
  22.  
  23. xonLoad 
  24. GuiOpen GoSub.gc
  25.  
  26. xonClose
  27. GuiQuit GoSub.gc
  28.  
  29. ; ---- The main contents start here ...
  30. ;        The texts
  31.  
  32. Text 80 2 100 12 'GoSub and xRoutine' 206 NOBOX 
  33. Text 80 20 200 10 'Click on the "Gosub"' 20 NOBOX
  34. Text 80 30 200 10 'buttons to see the action.' 26 NOBOX
  35. Text 80 114 200 10 'Then read the script.' 22 NOBOX
  36. Text 20 27 32 12 'In' 2 NOBOX
  37. Text 18 113 32 12 'Out' 3 NOBOX
  38.  
  39. ;  Three buttons to call the subroutines
  40. ;  The calls themselves are simple :  gosub GuiName RoutineName
  41. ;  The RoutineNames must be used in 'xRoutine' commands (see below)
  42.  
  43. xButton 120 50 80 12 'Gosub 1'
  44. gosub GoSub.gc SubRoutine1
  45. xButton 120 70 80 12 'Gosub 2'
  46. gosub GoSub.gc SubRoutine2
  47. xButton 120 90 80 12 'Gosub 3'
  48. gosub GoSub.gc SubRoutine3
  49.  
  50. ;       Labels and empty strings for the output
  51. ;       from the subroutines
  52.  
  53. Text 14 140 34 16 ' 1' 2 BOX
  54. gadid 1
  55. Text 14 160 34 16 ' 2' 2 BOX
  56. gadid 2
  57. Text 14 180 34 16 ' 3' 2 BOX
  58. gadid 3
  59.  
  60. Text 60 142 34 16 ' ' 30 NOBOX
  61. gadid 4
  62. Text 60 162 34 16 ' ' 30 NOBOX
  63. gadid 5
  64. Text 60 172 34 16 ' ' 30 NOBOX
  65. gadid 6
  66. Text 60 182 34 16 ' ' 30 NOBOX
  67. gadid 7
  68.  
  69. ; ----  Here are the subroutines themselves.  All of this is :
  70.  
  71. ;  Very easy to call repeatedly if needed.
  72. ;  Well clear of the main script (especially useful for
  73. ;  complex arithmetic or file-handling procedures).
  74. ;  Very satisfying, because it is 'modular' programming,
  75. ;  and we are always being told that that's the best.
  76.  
  77. ;  In fact, these examples are utterly trivial, since all they do is
  78. ;  update the contents of 7 text gadgets which are already in place.
  79.  
  80. ;  The xRoutine names MUST match those called by the 'gosub' commands.
  81.   
  82. xRoutine SubRoutine1
  83. Update GoSub.gc 1 ' 1'
  84. Update GoSub.gc 2 '  '
  85. Update GoSub.gc 3 '  '
  86. Update GoSub.gc 4 "Subroutine 1 advises :"
  87. Update GoSub.gc 5 " Subroutines are easy to"
  88. Update GoSub.gc 6 " call when you have any"
  89. Update GoSub.gc 7 " repetitive tasks."
  90.  
  91. xRoutine SubRoutine2
  92. Update GoSub.gc 1 '  '
  93. Update GoSub.gc 2 ' 2'
  94. Update GoSub.gc 3 '  '
  95. Update GoSub.gc 4 "Subroutine 2 suggests :"
  96. Update GoSub.gc 5 " Subroutines can help keep"
  97. Update GoSub.gc 6 " your main script clear"
  98. Update GoSub.gc 7 " and easier to read."
  99.  
  100. xRoutine SubRoutine3
  101. Update GoSub.gc 1 '  '
  102. Update GoSub.gc 2 '  '
  103. Update GoSub.gc 3 ' 3'
  104. Update GoSub.gc 4 "Subroutine 3 proclaims :"
  105. Update GoSub.gc 5 " Subroutines are an example"
  106. Update GoSub.gc 6 " of modular programming."
  107. Update GoSub.gc 7 " They MUST be good."
  108.